package com.baidu.location;

import android.app.Service;
import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.Process;
import android.util.Log;
import java.io.File;

public final class f extends Service
{
  static final int A = 56;
  static final int C = 54;
  static final int E = 55;
  static final int I = 51;
  static final int J = 53;
  static final int K = 13;
  static final int N = 22;
  static String O = Environment.getExternalStorageDirectory().getPath() + "/baidu/tempdata";
  static final int P = 65;
  static final int Q = 21;
  static final int R = 61;
  static final int S = 64;
  static final int U = 11;
  static final int a = 25;
  static final int jdField_byte = 12;
  static final int c = 42;
  static final int jdField_case = 14;
  static final float jdField_char = 2.6F;
  static final int d = 3000;
  static final int e = 52;
  static final int f = 31;
  public static final String g = "baidu_location_service";
  static final int jdField_goto = 24;
  static final int jdField_if = 1000;
  static final int jdField_int = 43;
  static final int j = 3000;
  static final int l = 57;
  static final int m = 23;
  static final int o = 27;
  static final int p = 15;
  static final int s = 63;
  static final int t = 2000;
  static final int jdField_try = 26;
  static final int u = 62;
  static final int w = 91;
  static final int x = 71;
  static final int y = 41;
  static final int z = 81;
  private e.c B = null;
  private b D = null;
  private boolean F = false;
  private Location G = null;
  private a H = null;
  private c L = null;
  private c.a M = null;
  private String T = null;
  private e.c b = null;
  final Handler jdField_do = new b();
  private boolean jdField_else = false;
  private e.c jdField_for = null;
  private String h = null;
  private long i = 0L;
  private e k = null;
  private c.a jdField_long = null;
  final Messenger n = new Messenger(this.jdField_do);
  private boolean jdField_new = true;
  private c.a q = null;
  private boolean r = false;
  private long v = 0L;
  private String jdField_void = null;

  private String a(String paramString)
  {
    j.a("baidu_location_service", "generate locdata ...");
    if (((this.M == null) || (!this.M.jdField_if())) && (this.L != null))
      this.M = this.L.a();
    label115: String str1;
    if (this.M != null)
    {
      j.jdField_if("baidu_location_service", this.M.a());
      if (((this.B == null) || (!this.B.jdField_if())) && (this.k != null))
        this.B = this.k.jdField_new();
      if (this.B == null)
        break label278;
      j.jdField_if("baidu_location_service", this.B.jdField_byte());
      if ((this.D == null) || (!this.D.jdField_case()))
        break label289;
      this.G = this.D.jdField_do();
      label143: a locala = this.H;
      str1 = null;
      if (locala != null)
        str1 = this.H.jdField_try();
      if (3 != g.jdField_do(this))
        break label297;
    }
    label278: label289: label297: Object[] arrayOfObject;
    for (String str2 = "&cn=32"; ; str2 = String.format("&cn=%d", arrayOfObject))
    {
      if (this.jdField_new)
        str2 = str2 + "&rq=1";
      String str3 = str2 + str1;
      if (paramString != null)
        str3 = paramString + str3;
      return j.a(this.M, this.B, this.G, str3, 0);
      j.jdField_if("baidu_location_service", "cellInfo null...");
      break;
      j.jdField_if("baidu_location_service", "wifi list null");
      break label115;
      this.G = null;
      break label143;
      arrayOfObject = new Object[1];
      arrayOfObject[0] = Integer.valueOf(this.L.jdField_new());
    }
  }

  private void a()
  {
    if (this.D == null);
    do
    {
      return;
      j.a("baidu_location_service", "on new gps...");
      Location localLocation = this.D.jdField_do();
      if ((this.D.jdField_case()) && (k.jdField_if(localLocation)) && (this.L != null) && (this.k != null) && (this.H != null))
      {
        if (this.k != null)
          this.k.jdField_for();
        k.a(this.L.a(), this.k.jdField_do(), localLocation, this.H.jdField_try());
      }
    }
    while ((this.H == null) || (!this.D.jdField_case()));
    this.H.jdField_if(this.D.jdField_if());
  }

  private void a(int paramInt)
  {
    j.a("baidu_location_service", "on network exception");
    j.jdField_if("baidu_location_service", "on network exception");
    this.T = null;
    this.b = null;
    this.q = null;
    String str1 = "{\"result\":{\"time\":\"" + j.a() + "\",\"error\":\"63\"}}";
    boolean bool = j.jdField_do;
    String str2 = null;
    if (bool)
    {
      c.a locala = this.L.a();
      str2 = null;
      if (locala != null)
        str2 = h.a(locala.jdField_if, locala.jdField_for, locala.jdField_try);
    }
    if ((str2 == null) || (str2.length() == 0))
      str2 = str1;
    if (this.H != null)
      this.H.a(str2, paramInt);
    if (paramInt == 21)
      jdField_new();
  }

  private void a(Message paramMessage)
  {
    j.a("baidu_location_service", "manual upload ...");
    double d1 = paramMessage.getData().getDouble("x");
    double d2 = paramMessage.getData().getDouble("y");
    String str = paramMessage.getData().getString("addr");
    if ((this.L != null) && (this.k != null) && (this.H != null))
      k.a(this.L.a(), this.k.jdField_do(), this.H.jdField_try(), d1, d2, str);
    jdField_int();
  }

  private void a(Message paramMessage, int paramInt)
  {
    j.a("baidu_location_service", "on network success");
    j.jdField_if("baidu_location_service", "on network success");
    String str = (String)paramMessage.obj;
    j.a("baidu_location_service", "network:" + str);
    if (this.H != null)
      this.H.a(str, paramInt);
    int i1;
    if (j.a(str))
      if (paramInt == 21)
      {
        this.T = str;
        i1 = j.jdField_if(str, "ssid\":\"", "\"");
        if ((i1 == -2147483648) || (this.b == null))
          break label449;
      }
    label449: for (this.h = this.b.jdField_if(i1); ; this.h = null)
    {
      double d1 = j.jdField_do(str, "radius\":\"", "\"");
      double d2 = j.jdField_do(str, "x\":\"", "\"");
      double d3 = j.jdField_do(str, "y\":\"", "\"");
      if ((d1 != 4.9E-324D) && (d2 != 4.9E-324D) && (d3 != 4.9E-324D) && ((this.b == null) || (this.b.jdField_int() == 0)))
        h.a(this.q, d2, d3, (float)d1);
      double d4 = j.jdField_do(str, "a\":\"", "\"");
      if (d4 != 4.9E-324D)
        k.a(d4, j.jdField_do(str, "b\":\"", "\""), j.jdField_do(str, "c\":\"", "\""), j.jdField_do(str, "b\":\"", "\""));
      int i2 = j.jdField_if(str, "rWifiN\":\"", "\"");
      if (i2 > 15)
        j.jdField_new = i2;
      int i3 = j.jdField_if(str, "rWifiT\":\"", "\"");
      if (i3 > 500)
        j.jdField_for = i3;
      float f1 = j.a(str, "hSpeedDis\":\"", "\"");
      if (f1 > 5.0F)
        j.jdField_case = f1;
      float f2 = j.a(str, "mSpeedDis\":\"", "\"");
      if (f2 > 5.0F)
        j.jdField_if = f2;
      float f3 = j.a(str, "mWifiR\":\"", "\"");
      if ((f3 < 1.0F) && (f3 > 0.2D))
        j.jdField_char = f3;
      if (paramInt == 21)
        jdField_new();
      return;
      this.jdField_void = str;
      break;
      if (paramInt == 21)
      {
        this.T = null;
        break;
      }
      this.jdField_void = null;
      break;
    }
  }

  private boolean a(c.a parama)
  {
    boolean bool = true;
    if (this.L == null);
    do
    {
      return false;
      this.M = this.L.a();
    }
    while (this.M == parama);
    if ((this.M == null) || (parama == null))
      return bool;
    if (!parama.a(this.M));
    while (true)
    {
      return bool;
      bool = false;
    }
  }

  private boolean a(e.c paramc)
  {
    boolean bool = true;
    if (this.k == null);
    do
    {
      return false;
      this.B = this.k.jdField_new();
    }
    while (paramc == this.B);
    if ((this.B == null) || (paramc == null))
      return bool;
    if (!paramc.a(this.B));
    while (true)
    {
      return bool;
      bool = false;
    }
  }

  private void jdField_byte()
  {
    if ((this.T != null) && (g.jdField_if(this)))
      g.jdField_else();
  }

  private void jdField_case()
  {
    j.a("baidu_location_service", "on switch gps ...");
    if (this.H == null);
    do
    {
      return;
      if (this.H.jdField_for())
      {
        if (this.D == null)
          this.D = new b(this, this.jdField_do);
        this.D.jdField_int();
        return;
      }
    }
    while (this.D == null);
    this.D.a();
    this.D = null;
  }

  private void jdField_char()
  {
    if (this.H != null)
      this.H.jdField_new();
  }

  private void jdField_do()
  {
    if (g.jdField_if(this))
      g.jdField_else();
  }

  private void jdField_do(Message paramMessage)
  {
    if (this.H != null)
      this.H.jdField_for(paramMessage);
    if (this.k != null)
      this.k.jdField_try();
  }

  private void jdField_for()
  {
  }

  private void jdField_for(Message paramMessage)
  {
    if (System.currentTimeMillis() - this.v < 3000L)
    {
      j.a("baidu_location_service", "request too frequency ...");
      if (this.jdField_void != null)
        this.H.a(this.jdField_void, 26);
    }
    while (this.H == null)
      return;
    String str = a(this.H.a(paramMessage));
    if (this.h != null)
    {
      str = str + this.h;
      this.h = null;
    }
    g.jdField_do(this);
    if (g.jdField_if(str, this.jdField_do))
    {
      this.jdField_long = this.M;
      this.jdField_for = this.B;
    }
    while (true)
    {
      this.v = System.currentTimeMillis();
      return;
      j.a("baidu_location_service", "request poi error ..");
    }
  }

  private void jdField_if()
  {
    j.a("baidu_location_service", "on new wifi ...");
    if (this.r)
    {
      jdField_int();
      this.r = false;
    }
  }

  private void jdField_if(Message paramMessage)
  {
    if ((paramMessage == null) || (paramMessage.obj == null))
      j.a("baidu_location_service", "Gps updateloation is null");
    Location localLocation;
    do
    {
      do
      {
        do
        {
          return;
          localLocation = (Location)paramMessage.obj;
        }
        while (localLocation == null);
        j.a("baidu_location_service", "on update gps...");
      }
      while ((!k.jdField_if(localLocation)) || (this.L == null) || (this.k == null) || (this.H == null));
      if (this.k != null)
        this.k.jdField_for();
    }
    while (j.c != true);
    k.a(this.L.a(), this.k.jdField_do(), localLocation, this.H.jdField_try());
  }

  private void jdField_int()
  {
    if (this.F)
      return;
    if (System.currentTimeMillis() - this.i < 1000L)
    {
      j.a("baidu_location_service", "request too frequency ...");
      if (this.T != null)
      {
        this.H.a(this.T);
        jdField_new();
        return;
      }
    }
    j.a("baidu_location_service", "start network locating ...");
    j.jdField_if("baidu_location_service", "start network locating ...");
    this.F = true;
    if ((!a(this.b)) && (!a(this.q)) && (this.T != null))
    {
      this.H.a(this.T);
      jdField_new();
      return;
    }
    String str1 = a(null);
    if (str1 == null)
    {
      String str3 = "{\"result\":{\"time\":\"" + j.a() + "\",\"error\":\"62\"}}";
      this.H.a(str3);
      jdField_new();
      return;
    }
    if (this.h != null)
    {
      str1 = str1 + this.h;
      this.h = null;
    }
    if (g.a(str1, this.jdField_do))
    {
      this.q = this.M;
      this.b = this.B;
    }
    while (true)
    {
      if (this.jdField_new == true)
      {
        c.a locala = this.L.a();
        if (locala == null)
          break;
        String str2 = h.a(locala.jdField_if, locala.jdField_for, locala.jdField_try);
        if ((str2 != null) && (!str2.equals("")))
          this.H.a(str2);
        this.jdField_new = false;
      }
      this.i = System.currentTimeMillis();
      return;
      j.a("baidu_location_service", "request error ..");
    }
  }

  private void jdField_int(Message paramMessage)
  {
    j.a("baidu_location_service", "on request location ...");
    j.jdField_if("baidu_location_service", "on request location ...");
    if (this.H == null)
      return;
    if ((this.H.jdField_do(paramMessage) == 1) && (this.D != null) && (this.D.jdField_case()))
    {
      j.a("baidu_location_service", "send gps location to client ...");
      this.H.a(this.D.jdField_if(), paramMessage);
      return;
    }
    if (this.jdField_new)
    {
      jdField_int();
      return;
    }
    if ((this.k != null) && (this.k.jdField_for()))
    {
      this.r = true;
      this.jdField_do.postDelayed(new a(null), 2000L);
      return;
    }
    jdField_int();
  }

  private void jdField_new()
  {
    this.F = false;
    jdField_byte();
  }

  private void jdField_new(Message paramMessage)
  {
    if (this.H != null)
      this.H.jdField_if(paramMessage);
  }

  private void jdField_try()
  {
    j.a("baidu_location_service", "on new cell ...");
  }

  private void jdField_try(Message paramMessage)
  {
    if (this.H != null)
      this.H.jdField_int(paramMessage);
  }

  public IBinder onBind(Intent paramIntent)
  {
    return this.n.getBinder();
  }

  public void onCreate()
  {
    this.L = new c(this, this.jdField_do);
    this.k = new e(this, this.jdField_do);
    this.H = new a(this.jdField_do);
    this.L.jdField_do();
    this.k.jdField_int();
    this.jdField_else = true;
    this.F = false;
    this.r = false;
    j.a("baidu_location_service", "onCreate");
    Log.d("baidu_location_service", "baidu location service start1 ..." + Process.myPid());
  }

  public void onDestroy()
  {
    if (this.L != null)
      this.L.jdField_byte();
    if (this.k != null)
      this.k.jdField_case();
    if (this.D != null)
      this.D.a();
    k.jdField_if();
    h.jdField_if();
    this.F = false;
    this.r = false;
    this.jdField_else = false;
    j.a("baidu_location_service", "onDestroy");
    Log.d("baidu_location_service", "baidu location service stop ...");
  }

  private class a
    implements Runnable
  {
    private a()
    {
    }

    public void run()
    {
      if (f.jdMethod_do(f.this) == true)
      {
        f.a(f.this, false);
        f.jdMethod_case(f.this);
      }
    }
  }

  public class b extends Handler
  {
    public b()
    {
    }

    public void handleMessage(Message paramMessage)
    {
      if (f.jdMethod_if(f.this) == true)
        switch (paramMessage.what)
        {
        default:
        case 11:
        case 12:
        case 15:
        case 21:
        case 26:
        case 24:
        case 31:
        case 51:
        case 57:
        case 52:
        case 22:
        case 25:
        case 41:
        case 81:
        case 91:
        case 53:
        case 62:
        case 63:
        case 64:
        case 65:
        }
      while (true)
      {
        super.handleMessage(paramMessage);
        return;
        f.jdMethod_do(f.this, paramMessage);
        continue;
        f.a(f.this, paramMessage);
        continue;
        f.jdMethod_new(f.this, paramMessage);
        continue;
        f.a(f.this, paramMessage, 21);
        continue;
        f.a(f.this, paramMessage, 26);
        continue;
        f.jdMethod_int(f.this, paramMessage);
        continue;
        f.jdMethod_byte(f.this);
        continue;
        f.jdMethod_new(f.this);
        continue;
        f.jdMethod_for(f.this, paramMessage);
        continue;
        f.jdMethod_for(f.this);
        continue;
        f.jdMethod_if(f.this, paramMessage);
        continue;
        f.jdMethod_try(f.this, paramMessage);
        continue;
        f.jdMethod_try(f.this);
        continue;
        f.a(f.this);
        continue;
        f.jdMethod_int(f.this);
        continue;
        f.jdMethod_char(f.this);
        continue;
        f.a(f.this, 21);
        continue;
        f.a(f.this, 26);
      }
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.baidu.location.f
 * JD-Core Version:    0.6.2
 */